package HomeWork;

import java.util.Scanner;

public class Test06Opt {
    public static void main(String[] args) {
        int customer = selectCustomer();
        int money = inputMoney();

        customerCase(customer,money);
    }

    public static int selectCustomer(){
        int a;
        Scanner sc = new Scanner(System.in);
        do{
            System.out.println("请录入顾客类别（【0】为普通顾客，【1】为会员）：");
            a = sc.nextInt();
            if(a == 0 || a == 1){
                return a;
            }else{
                System.out.println("类别错误，请重新录入：");
                System.out.println("------------------------");
            }
        }while(true);
    }

    public static int inputMoney(){
        int money;
        Scanner sc = new Scanner(System.in);
        do{
            System.out.println("请输入购物金额：");
            money = sc.nextInt();
            if(money > 0){
                return money;
            }else{
                System.out.println("金额错误，请重新录入：");
                System.out.println("------------------------");
            }
        }while(true);
    }

    public static void customerCase(int a,int money){
        switch(a){
            case 0:
                System.out.print("普通顾客");
                customer(money);
                break;
            case 1:
                System.out.print("会员");
                vipCustomer(money);
                break;
            default:
                break;
        }
    }


    public static void customer(int money){
        if(money < 100){
            System.out.println("，不打折，应付"+money+"元");
        }else{
            System.out.println("，折前金额"+money+"元"+"，应付金额"+0.9*money);
        }
    }

    public static void vipCustomer(int money){
        if(money < 200){
            System.out.println("，折前金额"+money+"元"+"，应付金额"+0.8*money);
        }else{
            System.out.println("，折前金额"+money+"元"+"，应付金额"+0.75*money);
        }
    }
}
